<template>
	<view class="container">
		<view class="success">
			<view class="s-img">
				<image :src="$img_path('/course/pay_s.png')" mode="widthFix"></image>
			</view>
			<view class="p-text">
				支付成功
			</view>
			<view class="p-price">
				{{info.type==2 ? '余额' : '微信'}}支付 实付￥{{info.price}}
			</view>
			
			<view class="btn">
				<button class="back" @click="back">返回</button>
				<button class="look" @click="toOrderList">查看订单</button>
			</view>
		</view>
		
		<view class="recommend">
			<view class="title">
				<text>—— 你可能还喜欢 ——</text>
			</view>
			<view class="list">
				<view class="item" v-for="(item,i) in like_list" :key="item.id">
					<itemBox :styleType="1" :title_row="1" :goodsDetail="item" :imageStyle="{width:'344rpx',height:'344rpx'}">
						<text slot="center" style="margin-top: 16rpx;display: block;">销量：{{item.sales}}</text>
						<!-- <view slot="tagList" class="tagList">
							<view class="tag-item">
								标签标签
							</view>
							<view class="tag-item">
								标签
							</view>
							<view class="tag-item">
								标签标签
							</view>
						</view> -->
					</itemBox>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getLikes} from '@/utils/api/mallApi.js'
	import itemBox from '../../components/service-box/mall-item-box.vue'
	export default {
		components:{
			itemBox
		},
		data() {
			return {
				info:null,
				
				like_list:[],
				page:1,
				last_page:0,
				total:0,
				contentText: {
					contentdown: '上滑加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多了'
				},
				like_status:'',
			};
		},
		onLoad(options) {
			this.info = JSON.parse(options.info)
			this.getLikes()
		},
		// 滚动到底部
		onReachBottom(e) {
			if(this.page<this.last_page){
				this.page++
				this.getLikes()
			}
		},
		methods:{
			back(){
				uni.navigateBack({
					delta:2
				})
			},
			toOrderList(){
				uni.reLaunch({
					url:'/pagesMine/shopGoodsOrder/list/list',
				})
			},
			
			// 猜你喜欢
			getLikes(){
				this.like_status = 'contentrefresh'
				getLikes({
					pages:'cart',
					page:this.page
				}).then(res=>{
					this.last_page = res.data.last_page
					this.total = res.data.total
					if(this.page==1){
						this.like_list = res.data.data
					}else{
						this.like_list = [...res.data.data,...this.like_list]
					}
					if(this.page<res.data.last_page){
						this.like_status = 'contentdown'
					}else{
						this.like_status = 'contentnomore'
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.container{
	.success{
		background-color: #FFFFFF;
		padding: 40rpx 22rpx 52rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
		.s-img{
			width: 200rpx;
			height: 200rpx;
			image{
				width: 100%;
				height: 100%;
			}
			margin: 0 auto;
		}
		.p-text{
			font-weight: bold;
			font-size: 36rpx;
			color: #333333;
			line-height: 50rpx;
			margin-top: 40rpx;
			text-align: center;
		}
		.p-price{
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
			line-height: 42rpx;
			margin-top: 18rpx;
			text-align: center;
		}
		.btn{
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			.back{
				width: 300rpx;
				height: 96rpx;
				background: #FFFFFF;
				border-radius: 80rpx;
				border: 2rpx solid #E72A2A;
				font-weight: bold;
				font-size: 36rpx;
				color: #E72A2A;
				line-height: 96rpx;
			}
			.look{
				width: 300rpx;
				height: 96rpx;
				background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
				border-radius: 80rpx;
				font-weight: bold;
				font-size: 36rpx;
				color: #FFFFFF;
				line-height: 96rpx;
			}
		}
	}
	.recommend{
		margin-top: 20rpx;
		background-color: #FFFFFF;
		padding: 40rpx 22rpx 50rpx;
		box-sizing: border-box;
		.title{
			font-weight: bold;
			font-size: 36rpx;
			color: #333333;
			line-height: 50rpx;
			text-align: center;
		}
		.list{
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			.item{
				width: 344rpx;
				margin-top: 20rpx;
				.tagList{
					display: flex;
					align-items: center;
					margin-top: 16rpx;
					margin-bottom: 4rpx;
					.tag-item{
						// width: 118rpx;
						height: 34rpx;
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						border: 2rpx solid #0291FF;
						font-weight: 400;
						font-size: 20rpx;
						color: #0291FF;
						// line-height: 34rpx;
						text-align: center;
						margin-left: 12rpx;
						padding: 3rpx 12rpx;
						box-sizing: border-box;
						&:first-child{
							background: #FF6602;
							border-color: #FF6602;
							color: #FFFFFF;
							margin-left: 0;
						}
					}
				}
			}
		}
	}
}
</style>
